import { defineComponent } from 'vue';
import { Button } from 'ant-design-vue';
import { createElement } from './createElement';
import { AuditOutlined } from '@ant-design/icons-vue';

const SwitchNode = defineComponent({
  name: 'SwitchNode',
  setup() {
    const handleCreateUserTask = (e: Event) => {
      createElement(e, 'UserTask','转换节点', { UserTaskType: 'ccTask' });
    };
    const getAssetsFile = (fileName: string) => {
        return new URL(`/src/assets/icons/${fileName}`, import.meta.url).href;
      }
    
    return () => (
      <Button
        ghost
        type="primary"
        onClick={handleCreateUserTask}
        draggable="true"
        onDragstart={handleCreateUserTask}
      >
        <span>
          <img 
            src={getAssetsFile('csjd.png')} 
            alt="转换节点" 
            style={{ width: '14px', height: '14px', marginRight: '6px' }} 
          />
          转换节点
        </span>
      </Button>
    );
  },
});

export default SwitchNode;